package com.financialDog.javaTool;

import com.xwintop.xcore.util.javafx.JavaFxSystemUtil;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;

import java.net.URL;
import java.util.ResourceBundle;

@Slf4j
public class ReportMergeToolMain extends Application {
    public static void main(String[] args) {
        try {    
            launch(args);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void start(Stage primaryStage) throws Exception {

        FXMLLoader fxmlLoader = new FXMLLoader();
        fxmlLoader.setLocation(ReportMergeToolMain.class.getResource("/com/financialDog/javaTool/fxmlView/reportTools/ReportMergeTool.fxml"));
        ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.ReportMergeTool");
        fxmlLoader.setResources(resourceBundle);

        Parent root = fxmlLoader.load();
        double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8);
        primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1]));
        primaryStage.show();
//        FXMLLoader fXMLLoader = ReportMergeToolMain.getFXMLLoader();
//        ResourceBundle resourceBundle = fXMLLoader.getResources();
//
//        Parent root = fXMLLoader.load();
//        primaryStage.setResizable(true);
//        primaryStage.setTitle(resourceBundle.getString("Title"));
////        primaryStage.getIcons().add(new Image("/images/icon.jpg"));
//        double[] screenSize = JavaFxSystemUtil.getScreenSizeByScale(0.74, 0.8);
//        primaryStage.setScene(new Scene(root, screenSize[0], screenSize[1]));
//        primaryStage.show();
//        primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
//            @Override
//            public void handle(WindowEvent event) {
//                System.exit(0);
//            }
//        });
    }

    public static FXMLLoader getFXMLLoader() {
        ResourceBundle resourceBundle = ResourceBundle.getBundle("locale.ReportMergeTool");
        URL url = Object.class.getResource("/com/financialDog/javaTool/fxmlView/reportTools/ReportMergeTool.fxml");
        FXMLLoader fXMLLoader = new FXMLLoader(url, resourceBundle);
        return fXMLLoader;
    }
}